package com.ruoyi.app.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.domain.dto.*
import com.ruoyi.app.service.LoginApiService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@Api(tags = ["登录相关接口"])
@RequestMapping("/api/login")
class LoginApiController {

    @Autowired
    private lateinit var loginApiService: LoginApiService

    @ApiOperation("三方登陆接口(qq 微信登陆)")
    @PostMapping("threeLogin")
    fun threeLogin(threeLoginDto: ThreeLoginDto): Data<String> = loginApiService.threeLogin(threeLoginDto)

    @ApiOperation("手机号验证码登录")
    @PostMapping("phoneLogin")
    fun phoneLogin(phoneLoginDto: PhoneLoginDto): Data<String> = loginApiService.phoneLogin(phoneLoginDto)

    @ApiOperation("一键登陆")
    @PostMapping("oneKeyLogin")
    fun oneKeyLogin(oneKeyLoginDto: OneKeyLoginDto): Data<String> = loginApiService.oneKeyLogin(oneKeyLoginDto)

    @ApiOperation("发送短信验证码")
    @GetMapping("sendSms/{phone}")
    fun sendSms(@PathVariable phone: String): Data<String> = loginApiService.sendSms(phone)

    @ApiOperation("手机号注册")
    @PostMapping("register")
    fun register(registerDto: RegisterDto): Data<String> = loginApiService.register(registerDto)

    @ApiOperation("忘记密码")
    @PostMapping("forgetPassword")
    fun forgetPassword(registerDto: RegisterDto): Data<Boolean> = loginApiService.forgetPassword(registerDto)

    @ApiOperation("手机号密码登录")
    @PostMapping("passwordLogin")
    fun passwordLogin(phonePasswordLoginDto: PhonePasswordLoginDto): Data<String> = loginApiService.passwordLogin(phonePasswordLoginDto)


    @ApiOperation("获取用户协议")
    @GetMapping("getUserAgreement")
    fun getUserAgreement(): Data<String?> = loginApiService.getUserAgreement()

    @ApiOperation("获取隐私政策")
    @GetMapping("getPrivacyPolicy")
    fun getPrivacyPolicy(): Data<String?> = loginApiService.getPrivacyPolicy()

}